function [action,alg]=action_selector(alg)

global EXP_RATE

i1=alg.prodcount+1;



if alg.Pi(i1,1)>=alg.Pi(i1,2)
    greedy_action=1;
else
    greedy_action=2;
end

if greedy_action==1
    non_greedy_action=2;
else
    non_greedy_action=1;
end


number=rand(1);

if number<EXP_RATE 
    action=non_greedy_action;
    alg.flag=2;
else 
    action=greedy_action;
    alg.flag=1;
end

%EXP_RATE=0.7*1000/(500+alg.iter);

%EXP_RATE=EXP_RATE*0.999999;